<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function createProxy(value = 0) {
        return new Proxy(
          {},
          {
            get(target, key) {
              if (key === Symbol.toPrimitive) {
                return () => value;
              }
              return createProxy(value + Number(key));
            },
          }
        );
      }

      const add = createProxy();
      const a = add[1][2][3] + 4; // 10
      const b = add[10][20] + 30; // 60
      const c = add[100] + 0; // 100
      console.log(a, b, c);
    </script>
  </body>
</html>
